#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>

int main()
{
    int fd = open("./bite.txt",O_CREAT | O_WRONLY,S_IRWXU);

    const char* buf = "Linux so easy!";    

    ssize_t n = write(fd,buf,strlen(buf));
    if(-1 == n)
    {
        perror("write fail:");
        exit(-1);
    }
    close(fd);

    printf("-------------------------------------\n");

    int fd1 = open("./bite.txt",O_RDONLY);
    char tem[128] = {0};
    read(fd1,tem,n);
    printf("%s\n",tem);
    
    close(fd1);
    return 0;
}